<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>账号</title>

    <script charset="utf-8" type="text/javascript" src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="/js/com.wxd.js"></script>
    <script charset="utf-8" type="text/javascript" src="/pageview.js"></script>

    <link rel="stylesheet" type="text/css" href="/style/com.wxd.css"/>
    <link rel="stylesheet" type="text/css" href="/style/table.css"/>

    <style>
        html, body {display: block;width: 100%;height: 100%;overflow: hidden;overflow-x: auto;background: rgb(255, 255, 255);}

        a:link {color: #0866b4;}

        a:visited { color: #0866b4;}

        label {padding-left: 5px;padding-right: 5px;}

    </style>

    <script>

        function parentLoading() {
            wxd.loading();
        }

        function parentLoading_close() {
            wxd.loading_close();
        }

        function parentNotice(content, isError, closeTime) {
            wxd.message.notice(content, isError, closeTime);
        }

        function parentAlert(msg) {
            wxd.message.alert(
                msg,
                "提示：",
                "关闭",
                () => {
                    setTimeout(() => {
                        $("#div_load_box").parent().remove();
                        search();
                    }, 1);
                }
            );
        }

        function ban(account) {
            let urlQuery = new wxd.Map().loadSearch();
            urlQuery.put("account", account);
            wxd.netty.post("/user/ban", urlQuery.toString(),
                function (responseText) {
                    wxd.message.alert(
                        JSON.stringify(responseText),
                        "提示：",
                        "关闭",
                        () => {
                            setTimeout(() => {
                                search();
                            }, 1);
                        }
                    );
                },
                (errorMsg) => {
                    wxd.message.alert("异常：" + errorMsg);
                },
                true, 30_000
            );
        }

        let pageView;

        function search() {
            wxd.loading();
            let urlQuery = new wxd.Map().loadSearch();
            urlQuery.put("account", $("#account").val());
            pageView.remoteGetData(urlQuery);
        }


        function createRow(index, row) {
            let tr = `
    <tr>
        <td tips="true" style="width: 170px;">
            <a href="#" onclick="ban(${row.account});return false;">禁止/启用</a>
            <a href="#" onclick="wxd.loadHtml('/user-pwd-reset.html?account=${row.account}','400px','140px',null,'-50px','-50px');return false;">重置密码</a>
        </td>
        <td tips="true" style="width: 40px;">${index}</td>
        <td tips="true" style="width: 140px;">${row.uid}</td>
        <td tips="true" style="width: 200px;">${row.account}</td>
        <td tips="true" style="width: 70px;">${row.admin}</td>
        <td tips="true" style="width: 140px;">${row.createTime}</td>
        <td tips="true" style="width: 140px;">${row.disConnect}</td>
        <td tips="true" style="width: 140px;"><a href="#" onclick="wxd.loadHtml('/author-routing.html?account=${row.account}','80%','60%')">查看</a></td>
        <td tips="true" style="width: 140px;"><a href="#" onclick="wxd.loadHtml('/author-game.html?account=${row.account}','80%','60%')">查看</a></td>
    </tr>
`;
            return tr;
        }

        let gameId = 0;

        $(() => {
            let urlQuery = new wxd.Map().loadSearch();
            gameId = urlQuery.get("gameId");
            pageView = new PageView("/user/list", search, createRow);
            search();
        });

    </script>

</head>

<body>
<div class="btn_box" style="padding-left: 10px; padding-top: 8px; text-align: left;vertical-align: center;">
    <button type="button" onclick="wxd.loadHtml('/user-add.html','400px','240px',null,'-50px','-50px');">
        添加用户
    </button>
    <button type="button" onclick="search();">搜索</button>
    <br>
    <input id="user" type="text" value="" style="" onkeydown="if (event.keyCode===13)search();" placeholder="登录账号"/>
</div>
<div class="tableDom" style="position: absolute;left: 10px;top: 80px;right: 15px;bottom: 35px;">
    <table>
        <thead>
        <tr>
            <th style="width: 170px;">操作</th>
            <th style="width: 40px;">序号</th>
            <th style="width: 140px;">账号ID</th>
            <th style="width: 200px;">账号</th>
            <th style="width: 70px;">管理员</th>
            <th style="width: 140px;">创建时间</th>
            <th style="width: 140px;">禁止状态</th>
            <th style="width: 140px;">权限授权</th>
            <th style="width: 140px;">游戏授权</th>
        </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
</div>
</body>
</html>